import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../constants.dart';
import '../../../theme.dart';
import 'logic.dart';

class SettingsPage extends StatelessWidget {
  SettingsPage({Key? key}) : super(key: key);

  final SettingsLogic logic = Get.put(SettingsLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('设置'),
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back_ios,
            size: 16.w,
          ),
          onPressed: () {
            Get.back();
          },
        ),
      ),
      body: Padding(
        padding: EdgeInsets.all(kSpaceMedium),
        child: Column(
          children: [
            Ink(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(kRadiusMedium),
                  topRight: Radius.circular(kRadiusMedium),
                ),
              ),
              child: InkWell(
                onTap: () => logic.onClickChangePassword(),
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(kRadiusMedium),
                  topRight: Radius.circular(kRadiusMedium),
                ),
                child: _buildItem('修改登录密码'),
              ),
            ),
            Ink(
              decoration: const BoxDecoration(color: Colors.white),
              child: InkWell(
                onTap: () => logic.onClickSetPayPassword(),
                child: _buildItem('设置支付密码'),
              ),
            ),
            Ink(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(kRadiusMedium),
                  topRight: Radius.circular(kRadiusMedium),
                ),
              ),
              child: InkWell(
                onTap: () => logic.onClickAgreement(),
                child: _buildItem('用户协议'),
              ),
            ),
            Ink(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(kRadiusMedium),
                  bottomRight: Radius.circular(kRadiusMedium),
                ),
              ),
              child: InkWell(
                onTap: () => logic.onClickPrivacy(),
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(kRadiusMedium),
                  bottomRight: Radius.circular(kRadiusMedium),
                ),
                child: _buildItem('隐私政策'),
              ),
            ),
            Ink(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(kRadiusMedium),
                  bottomRight: Radius.circular(kRadiusMedium),
                ),
              ),
              child: InkWell(
                onTap: () => logic.onClickLogout(),
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(kRadiusMedium),
                  bottomRight: Radius.circular(kRadiusMedium),
                ),
                child: _buildItem('退出登录'),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildItem(String title) {
    return Padding(
      padding: EdgeInsets.all(kSpaceSmall),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            title,
            style: TextStyle(
              fontSize: kFontSizeSmall,
              color: AppColor.colorFontBlack,
            ),
          ),
          Icon(
            Icons.arrow_forward_ios,
            size: 16.w,
            color: AppColor.colorFontBlack,
          ),
        ],
      ),
    );
  }
}
